<?php


namespace app\api\controller;
use Zewail\Api\Facades\Response as ApiResponse;


/**
 * Class Sadmin
 * @title 管理员中心操作
 * @description 关于管理员的添加，删除,修改和登录
 */
class Sadmin
{
    private $sadminService = null;
    public function __construct()
    {
        $this->sadminService = new \app\api\service\Sadmin();
    }

    /**
     * @title 登录接口
     * @desc  {"0":"接口地址：/api/chklogin","1":"请求方式：POST","2":"接口备注：用于管理员登录验证"}
     * @param {"name":"name","type":"string","required":true,"default":"xxxx","desc":"用户名"}
     * @param {"name":"pw","type":"string","required":true,"default":"xxxx","desc":"密码"}
     * @return {"name":"code","type":"int","required":true,"desc":"返回码：200成功,205失败","level":1}
     * @return {"name":"message","type":"string","required":true,"desc":"详细信息","level":1}
     */
    public function chkLogin(){
        //接口代码
        $data= array();
        if("登陆成功"==$this->sadminService->chkLogin(request()->post("name"),request()->post("pw"))){
            $data["code"]=200;
            $data["message"]="登录成功";
            return ApiResponse::OK($data);
        }else{
            $data["code"]=205;
            $data["message"]="账号或密码错误";
            return ApiResponse::OK($data);
        }
    }

    /**
     * @title 管理员列表数据接口
     *
     */
    public function dataList(){

    }

    /**
     * @title 管理员添加和编辑验证
     */
    public function chkAddAndEdit(){

    }

    /**
     * 管理员资源更新
     */
    public function chkUpdate(){

    }

    /**
     * @title 管理员删除验证
     */
    public function delete(){

    }
}